﻿using System;
using Cesave.Domain.Core.Specification;
using Cesave.Domain.PermisosModule.Entities;
using Cesave.Domain.PermisosModule.Resources;

namespace Cesave.Domain.PermisosModule.Contracts.Juntas
{
	/// <summary>
	/// 
	/// </summary>
	public class JuntasByMunicipioSpecification
		: Specification<Junta>
	{

		#region Private properties

		/// <summary>
		/// 
		/// </summary>
		private Guid _municipioGuid = default(Guid);

		#endregion

		#region Constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="municipioGuid"></param>
		public JuntasByMunicipioSpecification(Guid municipioGuid)
		{
			if (municipioGuid == Guid.Empty)
				throw new InvalidOperationException(Messages.exception_InvalidArgument);
			_municipioGuid = municipioGuid;
		}

		#endregion

		#region Specification overrides

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override System.Linq.Expressions.Expression<Func<Junta, bool>> SatisfiedBy()
		{
			Specification<Junta> specification = new DirectSpecification<Junta>(junta => junta.MunicipioGuid == _municipioGuid);
			return specification.SatisfiedBy();
		}

		#endregion

	}
}
